<?php $filepointer = fopen("/home/web1/mariokartchallenger.com/htdocs/rss.xml", "w");

fputs ($filepointer, '<?xml version="1.0"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mario Kart Challenger</title><link>http://www.mariokartchallenger.com/</link><description>A place to find and share your Wii Friend Codes, meet new opponents, track your online racing statistics, and join clans in Mario Kart Wii.</description><language>en-us</language><pubDate>');

$pubdate = date('D, d M Y') . ' 00:00:01 CST';

fputs ($filepointer, $pubdate);

fputs ($filepointer, "</pubDate><lastBuildDate>");

fputs ($filepointer, date('D, d M Y h:i:s T'));

fputs ($filepointer, "</lastBuildDate><docs>http://cyber.law.harvard.edu/rss/rss.html</docs><generator>Mario Kart Challenger RSS Generator by zilli0n</generator><managingEditor>support@mariokartchallenger.com (User Support)</managingEditor><webMaster>support@mariokartchallenger.com (User Support)</webMaster><ttl>5</ttl>");

$todays_date = date("F j, Y"); 

$query = "SELECT * FROM gamematch WHERE matchdate = '$todays_date' ORDER BY matchtime DESC LIMIT 10";
$result = mysql_query($query);

while ($gamedata = mysql_fetch_array($result))
{
	$thehost = $gamedata['host'];
	$cleantime = date("D, d M Y h:i:s T", strtotime($gamedata['matchtime']));
	$nextquery = "SELECT * FROM user WHERE username = '$thehost'";
	$nextresult = mysql_query($nextquery);
	$userstuff = mysql_fetch_array($nextresult);
	$friendcode = $userstuff[gamecode];
	stringtoarray($friendcode);
	fputs ($filepointer, '<item><title>' . $gamedata[battlename] . ' - hosted by ' . $userstuff[nick]);
	fputs ($filepointer, '</title><link>http://www.mariokartchallenger.com/index.php?showroom=' . $gamedata[id] .'</link><description>Mario Kart Wii Friendcode : '. $friendcode[0] . $friendcode[1] . $friendcode[2] . $friendcode[3] . '-'. $friendcode[4] . $friendcode[5] . $friendcode[6] . $friendcode[7] . '-'. $friendcode[8] . $friendcode[9] . $friendcode[10] . $friendcode[11] . '</description><pubDate>' . $cleantime . '</pubDate><guid>http://www.mariokartchallenger.com/index.php?showroom=' . $gamedata[id] . '</guid></item>');
}

fputs ($filepointer, '<atom:link href="http://www.mariokartchallenger/rss.xml" rel="self" type="application/rss+xml" /></channel></rss>');

?>